package com.example.service;

import com.example.entity.BooksHistory;
import com.example.entity.BooksLike;
import com.example.mapper.BooksLikeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/*
书籍收藏业务处理
 */
@Service
public class BooksLikeService {

    @Resource
    private BooksLikeMapper booksLikeMapper;

    public void add(BooksLike booksLike) {
        booksLikeMapper.insert(booksLike);
    }

    public void deleteById(Integer id) {
        booksLikeMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        for (Integer id : ids){
            this.deleteById(id);
        }
    }

    public void updateById(BooksLike booksLike) {
        booksLikeMapper.updateById(booksLike);
    }

    public BooksLike selectById(Integer id) {
        return booksLikeMapper.selectById(id);
    }

    public List<BooksLike> selectAll(BooksLike booksLike) {
        return booksLikeMapper.selectAll(booksLike);
    }

    public PageInfo<BooksLike> selectPage(BooksLike booksLike, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<BooksLike> booksLikeList = booksLikeMapper.selectAll(booksLike);
        return PageInfo.of(booksLikeList);
    }
}
